import { takeEvery, put} from 'redux-saga/effects';
import { LOAD_APPLES_ASYNC, loadCarts } from '../actions/cart.actions';
import axios from 'axios';

// 向服务器端发送请求 获取购物车列表数据
function* handleLoadApplesAsync () {
  const { data } = yield axios.get('./apples.json');
  yield put(LOAD_APPLES_ASYNC(data))
}

export default function* cartSaga () {
  // load data
  yield takeEvery(loadCarts, handleLoadApplesAsync);
}